package com.rds.web.controller.pms;

import com.rds.common.annotation.Log;
import com.rds.common.core.controller.BaseController;
import com.rds.common.core.domain.AjaxResult;
import com.rds.common.core.page.TableDataInfo;
import com.rds.common.enums.BusinessType;
import com.rds.common.utils.poi.ExcelUtil;
import com.rds.system.domain.RdaPortal;
import com.rds.system.service.IRdaPortalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * portal组合Controller
 * @author rds
 * @date 2021-05-27
 */
@RestController
@RequestMapping("/pms/portal")
public class RdaPortalController extends BaseController
{
    @Autowired
    private IRdaPortalService rdaPortalService;

    /**
     * 查询portal组合列表
     */
    @PreAuthorize("@ss.hasPermi('pms:portal:list')")
    @GetMapping("/list")
    public TableDataInfo list(RdaPortal rdaPortal)
    {
        startPage();
        List<RdaPortal> list = rdaPortalService.selectRdaPortalList(rdaPortal);
        return getDataTable(list);
    }

    /**
     * 导出portal组合列表
     */
    @PreAuthorize("@ss.hasPermi('pms:portal:export')")
    @Log(title = "portal组合", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RdaPortal rdaPortal)
    {
        List<RdaPortal> list = rdaPortalService.selectRdaPortalList(rdaPortal);
        ExcelUtil<RdaPortal> util = new ExcelUtil<RdaPortal>(RdaPortal.class);
        return util.exportExcel(list, "portal");
    }

    /**
     * 获取portal组合详细信息
     */
    @PreAuthorize("@ss.hasPermi('pms:portal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rdaPortalService.selectRdaPortalById(id));
    }

    /**
     * 新增portal组合
     */
    @PreAuthorize("@ss.hasPermi('pms:portal:add')")
    @Log(title = "portal组合", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RdaPortal rdaPortal)
    {
        return toAjax(rdaPortalService.insertRdaPortal(rdaPortal));
    }

    /**
     * 修改portal组合
     */
    @PreAuthorize("@ss.hasPermi('pms:portal:edit')")
    @Log(title = "portal组合", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RdaPortal rdaPortal)
    {
        return toAjax(rdaPortalService.updateRdaPortal(rdaPortal));
    }

    /**
     * 删除portal组合
     */
    @PreAuthorize("@ss.hasPermi('pms:portal:remove')")
    @Log(title = "portal组合", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rdaPortalService.deleteRdaPortalByIds(ids));
    }

}
